<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>修改页面</h1>
<div>
    <input type="text" v-model="emp.id" readonly>
    <input type="text" v-model="emp.name">
    <input type="text" v-model="emp.sal">
    <input type="text" v-model="emp.job">
    <input type="button" value="修改" @click="update()">

</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>

        let v=new Vue({
                el:"body>div",
                data:{
                    emp:{id:0,name:"",sal:0,job:""}
                },
                methods:{
                    update(){
                        //发请求修改
                        axios.post("/update",v.emp).then(function () {
                            location.href="/select.html"
                            alert("修改成功！")
                        })
                    }
                },
            created:function () {
                    //得到地址栏中的id  location.search得到地址栏中的参数
                let id=location.search.split("=")[1];
                console.log("id="+id);
                //发请求获取员工信息,其它地方已经处理过select，不能重复
                axios.get("/selectById?id="+id).then(function (response) {
                    v.emp=response.data;
                })
            }
            })


</script>
</body>
</html>